package com.changdu.seatunnel.admin.service;

import java.util.List;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.changdu.seatunnel.admin.entity.DataKafkaTemplate;
import com.changdu.seatunnel.admin.mapper.DataKafkaTemplateMapper;

@Service
public class DataKafkaTemplateService extends ServiceImpl<DataKafkaTemplateMapper, DataKafkaTemplate> {

	/**
	 * 根据数据源ID查询Kafka模板
	 * @param syncConfigId
	 * @return
	 */
	public List<DataKafkaTemplate> getTemplatesBySyncConfigId(Long syncConfigId) {
		LambdaQueryWrapper<DataKafkaTemplate> wrapper = new LambdaQueryWrapper<DataKafkaTemplate>()
				.eq(DataKafkaTemplate::getSyncConfigId, syncConfigId);
		return list(wrapper);
	}
	
	/**
	 * 根据数据源ID查询Kafka模板
	 * @param syncConfigId
	 * @return
	 */
	public void deleteTemplatesBySyncConfigId(Long syncConfigId) {
		LambdaQueryWrapper<DataKafkaTemplate> wrapper = new LambdaQueryWrapper<DataKafkaTemplate>()
				.eq(DataKafkaTemplate::getSyncConfigId, syncConfigId);
		remove(wrapper);
	}	

}